package cn.chenxinjie.hrm.mapper;

import cn.chenxinjie.hrm.domain.Permission;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author chenxinjie
 * @since 2022-03-09
 */
@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {
    @Select("SELECT t3.* FROM t_user_role t1 \n" +
            "LEFT JOIN t_role_permission t2 ON t1.role_id = t2.role_id\n" +
            "LEFT JOIN t_permission t3 ON t2.permission_id = t3.id where t1.user_id = #{id}")
    List<Permission> findRolePermissionsById(Long id);
}
